Intro to R

ShareIT 3rd October 2024

Chris Brownlie

Me

  • R user since 2018
  • BW since October 2022
  • Management Decision Analytics - Employer Consulting
  • Recently returned from a 4 month sabbatical!

Assumptions

  • Know what a programming language is
  • Have heard of Python, maybe heard of R
  • Don’t know anything else about it

R is 31 years old

flowchart LR
    a[<b>1976</b> <br><br> 'S' first released]
    b[<b>1995</b> <br><br> 'R' first released]
    c[<b>1997</b> <br><br> CRAN founded]
    d[<b>2000</b> <br><br> R v1.0 release]
    e[<b>2012</b> <br><br> Shiny first released]
    f[<b>2018</b> <br><br> I start using R!]
    g[<b>2024</b> <br><br> R v4.4.1]
    a --> b
    b --> c
    c --> d
    d --> e
    e --> f
    f --> g
    classDef default fill:#276DC2,color:#ffffff,fontSize:30px

Who uses R?

TIOBE Rankings (all devs)

:::{.notes} - Developed by academics, which is probably why it is more popular in academia - Consistently in the top 15-20 most popular programming languages among software developers - Misleading as it is more popular with data scientists (currently no. 6 on PyPL, which looks at how often tutorials for that language are being googled) :::

PyPL rankings (Google searches)

:::{.notes} - Developed by academics, which is probably why it is more popular in academia - Consistently in the top 15-20 most popular programming languages among software developers - Misleading as it is more popular with data scientists (currently no. 6 on PyPL, which looks at how often tutorials for that language are being googled) :::

Kaggle rankings (Data Scientists)

How we use R: IDEs

RStudio

RStudio IDE screenshot

VS Code

VS Code screenshot

Positron

Positron IDE screenshot

How we use R: Package ecosystem

Why we use R: ‘but Python’?

The big debate

Is Python faster than R?

C vs Julia vs Python vs R

Why we use R: strengths

{tidyverse}

RMarkdown/Quarto

  • Dynamically generated documents
  • Static websites
  • Interactive elements

Shiny

  • Framework for developing web apps
  • Easy learning curve
  • Translates R to web stack

MDA’s Data Navigator Shiny App

R from an IT perspective

Under the hood

  • Interpreted
  • Single threaded
  • Memory inefficient

Dependency management

  • Docker & {renv}
  • {rix}
  • Linux vs Windows

Security considerations

  • Open source
  • Packages are checked/built before being accepted to CRAN
  • Always a risk, weigh the pros and cons

R doesn’t stop you from shooting yourself in the foot, but as long as you don’t aim the gun at your toes and pull the trigger, you won’t have a problem. - Hadley Wickham, Advanced R